public class MaopaoSort {
    public static void main(String[] args) {
        int[] a={45,9,46,72,61,354,55,79,12};
        bubbleSort(a);
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }

    }
    public static void bubbleSort(int[] arr){
        //冒泡排序的时间复杂度为O(n*n)
        int temp = 0;//临时变量
        for (int j = 0; j < arr.length - 1; j++) {

            for (int i = 0; i < arr.length-1 -j ; i++) {
                if (arr[i] > arr[i+1]){
                    //三角交换
                    temp = arr[i];
                    arr[i] = arr[i+1];
                    arr[i+1] = temp;
                }
            }
        }
    }


}